﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1FlexGrid;
    using C1.Win.C1FlexGrid.Util.BaseControls;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_RunSQL : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CmdExit")]
        private Button _CmdExit;
        [AccessedThroughProperty("CmdRun")]
        private Button _CmdRun;
        [AccessedThroughProperty("Main")]
        private SplitContainer _Main;
        [AccessedThroughProperty("Panel1")]
        private Panel _Panel1;
        [AccessedThroughProperty("TabPage1")]
        private TabPage _TabPage1;
        [AccessedThroughProperty("TabPage2")]
        private TabPage _TabPage2;
        [AccessedThroughProperty("TabResult")]
        private TabControl _TabResult;
        [AccessedThroughProperty("TxtMessage")]
        private TextBox _TxtMessage;
        [AccessedThroughProperty("TxtSQL")]
        private TextBox _TxtSQL;
        [AccessedThroughProperty("VSResults")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSResults;
        private IContainer components;

        [DebuggerNonUserCode]
        public Frm_RunSQL()
        {
            base.Load += new EventHandler(this.Frm_RunSQL_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.InitializeComponent();
        }

        private void CmdExit_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void CmdRun_Click(object sender, EventArgs e)
        {
            if (this.TxtSQL.Text.Trim() != "")
            {
                string pSQL = this.TxtSQL.Text.Trim().ToUpper();
                if (LVYModule.sLeft(this.TxtSQL.Text.Trim(), 6).ToUpper() == "SELECT")
                {
                    this.RunDataset(pSQL);
                }
                else
                {
                    this.RunNonQuery(pSQL);
                }
            }
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (this.components != null))
                {
                    this.components.Dispose();
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }

        private void Frm_RunSQL_Load(object sender, EventArgs e)
        {
            MyProject.Forms.Frm_Run.Hide();
            this.Main.Panel2.Hide();
            this.Main.SplitterDistance = this.Main.Height - 20;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_RunSQL));
            this.CmdRun = new Button();
            this.CmdExit = new Button();
            this.Panel1 = new Panel();
            this.Main = new SplitContainer();
            this.TxtSQL = new TextBox();
            this.TabResult = new TabControl();
            this.TabPage1 = new TabPage();
            this.VSResults = new C1.Win.C1FlexGrid.C1FlexGrid();
            this.TabPage2 = new TabPage();
            this.TxtMessage = new TextBox();
            this.Panel1.SuspendLayout();
            this.Main.Panel1.SuspendLayout();
            this.Main.Panel2.SuspendLayout();
            this.Main.SuspendLayout();
            this.TabResult.SuspendLayout();
            this.TabPage1.SuspendLayout();
            this.VSResults.BeginInit();
            this.TabPage2.SuspendLayout();
            this.SuspendLayout();
            Point point = new Point(0x2ca, 2);
            this.CmdRun.Location = point;
            this.CmdRun.Name = "CmdRun";
            Size size = new Size(0x53, 0x19);
            this.CmdRun.Size = size;
            this.CmdRun.TabIndex = 1;
            this.CmdRun.Text = "Run";
            this.CmdRun.UseVisualStyleBackColor = true;
            point = new Point(0x323, 2);
            this.CmdExit.Location = point;
            this.CmdExit.Name = "CmdExit";
            size = new Size(0x53, 0x19);
            this.CmdExit.Size = size;
            this.CmdExit.TabIndex = 2;
            this.CmdExit.Text = "Exit";
            this.CmdExit.UseVisualStyleBackColor = true;
            this.Panel1.BackgroundImage = ACCOUNTING.My.Resources.Resources.bgleft;
            this.Panel1.Controls.Add(this.CmdRun);
            this.Panel1.Controls.Add(this.CmdExit);
            this.Panel1.Dock = DockStyle.Top;
            point = new Point(0, 0);
            this.Panel1.Location = point;
            this.Panel1.Name = "Panel1";
            size = new Size(0x37e, 0x1d);
            this.Panel1.Size = size;
            this.Panel1.TabIndex = 4;
            this.Main.Dock = DockStyle.Fill;
            point = new Point(0, 0x1d);
            this.Main.Location = point;
            this.Main.Name = "Main";
            this.Main.Orientation = Orientation.Horizontal;
            this.Main.Panel1.Controls.Add(this.TxtSQL);
            this.Main.Panel2.Controls.Add(this.TabResult);
            size = new Size(0x37e, 0x222);
            this.Main.Size = size;
            this.Main.SplitterDistance = 0x114;
            this.Main.TabIndex = 0x7a;
            this.TxtSQL.Dock = DockStyle.Fill;
            point = new Point(0, 0);
            this.TxtSQL.Location = point;
            this.TxtSQL.Multiline = true;
            this.TxtSQL.Name = "TxtSQL";
            this.TxtSQL.ScrollBars = ScrollBars.Both;
            size = new Size(0x37e, 0x114);
            this.TxtSQL.Size = size;
            this.TxtSQL.TabIndex = 0;
            this.TabResult.Controls.Add(this.TabPage1);
            this.TabResult.Controls.Add(this.TabPage2);
            this.TabResult.Dock = DockStyle.Fill;
            point = new Point(0, 0);
            this.TabResult.Location = point;
            this.TabResult.Name = "TabResult";
            this.TabResult.SelectedIndex = 0;
            size = new Size(0x37e, 0x10a);
            this.TabResult.Size = size;
            this.TabResult.TabIndex = 4;
            this.TabPage1.Controls.Add(this.VSResults);
            point = new Point(4, 0x16);
            this.TabPage1.Location = point;
            this.TabPage1.Name = "TabPage1";
            Padding padding = new Padding(3);
            this.TabPage1.Padding = padding;
            size = new Size(0x376, 240);
            this.TabPage1.Size = size;
            this.TabPage1.TabIndex = 0;
            this.TabPage1.Text = "Results";
            this.TabPage1.UseVisualStyleBackColor = true;
            this.VSResults.AllowEditing = false;
            this.VSResults.AutoClipboard = true;
            this.VSResults.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.XpThemes;
            this.VSResults.ColumnInfo = "1,0,0,0,0,90,Columns:";
            this.VSResults.Dock = DockStyle.Fill;
            this.VSResults.ExtendLastCol = true;
            this.VSResults.KeyActionEnter = KeyActionEnum.MoveAcross;
            point = new Point(3, 3);
            this.VSResults.Location = point;
            padding = new Padding(0);
            this.VSResults.Margin = padding;
            this.VSResults.Name = "VSResults";
            this.VSResults.Rows.Count = 1;
            this.VSResults.Rows.DefaultSize = 0x11;
            size = new Size(880, 0xea);
            this.VSResults.Size = size;
            this.VSResults.StyleInfo = manager.GetString("VSResults.StyleInfo");
            this.VSResults.TabIndex = 120;
            this.TabPage2.Controls.Add(this.TxtMessage);
            point = new Point(4, 0x16);
            this.TabPage2.Location = point;
            this.TabPage2.Name = "TabPage2";
            padding = new Padding(3);
            this.TabPage2.Padding = padding;
            size = new Size(0x376, 240);
            this.TabPage2.Size = size;
            this.TabPage2.TabIndex = 1;
            this.TabPage2.Text = "Messages";
            this.TabPage2.UseVisualStyleBackColor = true;
            this.TxtMessage.Dock = DockStyle.Fill;
            point = new Point(3, 3);
            this.TxtMessage.Location = point;
            this.TxtMessage.Multiline = true;
            this.TxtMessage.Name = "TxtMessage";
            this.TxtMessage.ScrollBars = ScrollBars.Both;
            size = new Size(880, 0xea);
            this.TxtMessage.Size = size;
            this.TxtMessage.TabIndex = 1;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            size = new Size(0x37e, 0x23f);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.Main);
            this.Controls.Add(this.Panel1);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.Name = "Frm_RunSQL";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "SQL Query";
            this.Panel1.ResumeLayout(false);
            this.Main.Panel1.ResumeLayout(false);
            this.Main.Panel1.PerformLayout();
            this.Main.Panel2.ResumeLayout(false);
            this.Main.ResumeLayout(false);
            this.TabResult.ResumeLayout(false);
            this.TabPage1.ResumeLayout(false);
            this.VSResults.EndInit();
            this.TabPage2.ResumeLayout(false);
            this.TabPage2.PerformLayout();
            this.ResumeLayout(false);
        }

        public void RunDataset(string pSQL)
        {
            try
            {
                DataTable table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, pSQL, new IDataParameter[0]).Tables[0];
                this.Main.Panel2.Show();
                this.Main.SplitterDistance = (int) Math.Round((double) (((double) this.Main.Height) / 2.0));
                this.TabResult.SelectTab(0);
                this.VSResults.DataSource = table;
                this.TxtMessage.Text = Conversions.ToString(table.Rows.Count) + " row(s) affected ";
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                ProjectData.ClearProjectError();
            }
        }

        public void RunNonQuery(string pSQL)
        {
            try
            {
                int num = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, pSQL, new IDataParameter[0]);
                this.Main.Panel2.Show();
                this.Main.SplitterDistance = (int) Math.Round((double) (((double) this.Main.Height) / 2.0));
                this.TabResult.SelectTab(1);
                this.TxtMessage.Text = Conversions.ToString(num) + " row(s) affected ";
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
        }

        internal virtual Button CmdExit
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdExit;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdExit_Click);
                if (this._CmdExit != null)
                {
                    this._CmdExit.Click -= handler;
                }
                this._CmdExit = value;
                if (this._CmdExit != null)
                {
                    this._CmdExit.Click += handler;
                }
            }
        }

        internal virtual Button CmdRun
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdRun;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdRun_Click);
                if (this._CmdRun != null)
                {
                    this._CmdRun.Click -= handler;
                }
                this._CmdRun = value;
                if (this._CmdRun != null)
                {
                    this._CmdRun.Click += handler;
                }
            }
        }

        internal virtual SplitContainer Main
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Main;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Main = value;
            }
        }

        internal virtual Panel Panel1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._Panel1 = value;
            }
        }

        internal virtual TabPage TabPage1
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TabPage1;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TabPage1 = value;
            }
        }

        internal virtual TabPage TabPage2
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TabPage2;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TabPage2 = value;
            }
        }

        internal virtual TabControl TabResult
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TabResult;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TabResult = value;
            }
        }

        internal virtual TextBox TxtMessage
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtMessage;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtMessage = value;
            }
        }

        internal virtual TextBox TxtSQL
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtSQL;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._TxtSQL = value;
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSResults
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSResults;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                this._VSResults = value;
            }
        }
    }
}

